home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / c / dicepj20.lha / diceproject / sources / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-31  |  43.3 KB  |  1,532 lines

  1. /* This file contains empty template routines that
  2.  * the IDCMP handler will call uppon. Fill out these
  3.  * routines with your code or use them as a reference
  4.  * to create your program.
  5.  */
  6.  
  7. #include <exec/types.h>
  8. #include <exec/lists.h>
  9. #include <exec/memory.h>
  10. #include <exec/nodes.h>
  11. #include <exec/execbase.h>
  12. #include <intuition/intuition.h>
  13. #include <intuition/classes.h>
  14. #include <intuition/classusr.h>
  15. #include <intuition/imageclass.h>
  16. #include <intuition/gadgetclass.h>
  17. #include <libraries/gadtools.h>
  18. #include <libraries/asl.h>
  19. #include <libraries/locale.h>
  20. #include <libraries/amigaguide.h>
  21. #include <graphics/displayinfo.h>
  22. #include <graphics/gfxbase.h>
  23. #include <dos/datetime.h>
  24. #include <dos/dostags.h>
  25. #include <dos/exall.h>
  26.  
  27. #include <clib/alib_protos.h>
  28. #include <clib/exec_protos.h>
  29. #include <clib/dos_protos.h>
  30. #include <clib/iffparse_protos.h>
  31. #include <clib/asl_protos.h>
  32. #include <clib/intuition_protos.h>
  33. #include <clib/icon_protos.h>
  34. #include <clib/amigaguide_protos.h>
  35. #include <clib/wb_protos.h>
  36. #include <clib/gadtools_protos.h>
  37. #include <clib/graphics_protos.h>
  38. #include <clib/utility_protos.h>
  39. #include <clib/locale_protos.h>
  40.  
  41. #include <stdio.h>
  42. #include <stdlib.h>
  43. #include <string.h>
  44. #include <ctype.h>
  45.  
  46. #define CATCOMP_NUMBERS
  47.  
  48. #include "project.catalog.h"
  49.  
  50. #include "compiler.h"
  51.  
  52. #include "project.h"
  53.  
  54. /*  Variables pour AmigaGuide    */
  55.  
  56. struct Library *AmigaGuideBase;
  57.  
  58. char *Context[] = {
  59.     "Main",
  60.     NULL
  61. };
  62. struct NewAmigaGuide aghelp = { NULL,"project.guide", Scr,NULL,NULL,NULL,"Project Handler",HTF_LOAD_INDEX, Context,NULL,NULL,NULL,NULL, };
  63. struct NewAmigaGuide agdocs = { NULL,NULL, Scr,NULL,NULL,NULL,"Project Handler",HTF_LOAD_INDEX, Context,NULL,NULL,NULL,NULL, };
  64. AMIGAGUIDECONTEXT handlehelp,handledocs;
  65.  
  66. /*  Variables externes pour la localisation */
  67.  
  68. struct Library *LocaleBase=NULL;
  69. struct Catalog *Catalog;
  70.  
  71. extern struct NewGadget ParmsLineNGad[];
  72. extern UBYTE *MessWdt;
  73. extern UBYTE *ParmsLineWdt;
  74. extern UBYTE *CompileWdt;
  75. extern UBYTE *CompilerWdt;
  76. extern UBYTE *LinkerWdt;
  77. extern UBYTE *ScreenPrefsWdt;
  78. extern UBYTE *PalettePrefsWdt;
  79. extern struct NewGadget CompilerNGad[],LinkerNGad[],ScreenPrefsNGad[],PalettePrefsNGad[];
  80.  
  81. extern struct NewScreen ns;
  82.  
  83. extern UBYTE *Type0Labels[];
  84. extern struct Node Pens1Nodes[];
  85.  
  86. /*  Variables global de status    */
  87.  
  88. BOOL named = FALSE;
  89. BOOL saved = TRUE;
  90.  
  91. UWORD ROMVersion;
  92.  
  93. extern char *ParmsLine;
  94. extern void ProjectCloseCompilerOpt( BOOL );
  95. extern void ProjectCloseLinkerOpt( BOOL );
  96. extern void CloseScreenPrefs( BOOL );
  97. extern void ProjectCloseDirSet( BOOL );
  98. extern void ProjectCloseGenOpt( BOOL );
  99. extern struct TagItem *BuildScreenTags( void );
  100. extern void BuildDefScreen( struct TagItem * );
  101. extern void DeleteScreenTags( void );
  102.  
  103. struct List *ModuleList;
  104. struct Resource *ProjectScreen;
  105.  
  106. struct TagItem *ScreenTags;
  107.  
  108. struct ModuleNode *CurrentModule;
  109.  
  110. /*  Variables du menu options    */
  111.  
  112. /****************************************************************************
  113. ***                                      ***
  114. ***    Gestion de la liste des modules                   ***
  115. ***                                      ***
  116. ****************************************************************************/
  117.  
  118. /****************************************************************
  119. ***    Liste des modules au niveau de GadTools           ***
  120. ****************************************************************/
  121.  
  122. void DettachList( void ) {
  123.     GT_SetGadgetAttrs( ProjectGadgets[0] , ProjectWnd , NULL , GTLV_Labels , NULL , TAG_DONE );
  124. }
  125.  
  126. void AttachList( void ) {
  127.     GT_SetGadgetAttrs( ProjectGadgets[0] , ProjectWnd , NULL , GTLV_Labels , (long)ModuleList , TAG_DONE );
  128. }
  129.  
  130. /****************************************************************
  131. ***    Creation du nom devant être affiché dans la liste     ***
  132. ****************************************************************/
  133.  
  134. void MakeRealNameList( struct ModuleNode *mn ) {
  135.   char *name,*objfile;
  136.   struct FileInfoBlock fib;
  137.   char size[10];
  138.  
  139.     if ( stricmp( mn->directory , SourceDir ) )
  140.     name = mn->pathfile;
  141.     else
  142.     name = mn->filename;
  143.     mn->namelist = malloc( strlen(name) + 20 );
  144.     *mn->namelist = 0;
  145.     if ( mn->type=='c' && GetInfo( &fib , mn->pathfile ) ) {
  146.     ltoa( size , fib.fib_Size );
  147.     while( strlen( mn->namelist ) + strlen( size ) < 6 )
  148.         strcat( mn->namelist , " " );
  149.     strcat( mn->namelist , size );
  150.     } else
  151.     strcat( mn->namelist , "  --  " );
  152.     if ( mn->type == 'c' ) {
  153.     objfile = MakeObjectPath( mn->filename );
  154.     } else
  155.     objfile = strdup( mn->pathfile );
  156.     if ( GetInfo( &fib , objfile ) ) {
  157.     ltoa( size , fib.fib_Size );
  158.     while( strlen( mn->namelist ) + strlen( size ) < 13 )
  159.         strcat( mn->namelist , " " );
  160.     strcat( mn->namelist , size );
  161.     } else
  162.     strcat( mn->namelist , "   --  " );
  163.     free( objfile );
  164.     if ( IsCommented( mn->pathfile ) )
  165.     strcat( mn->namelist , "  * " );
  166.     else
  167.     strcat( mn->namelist , "    " );
  168.     strcat( mn->namelist , name );
  169.     mn->node.ln_Name = mn->namelist;
  170.     mn->name = &mn->namelist[17];
  171. }
  172.  
  173. /****************************************************************
  174. ***    Mise à jour des noms apparaissant dans la liste       ***
  175. ****************************************************************/
  176.  
  177. long SelectModule;
  178.  
  179. void UpDateSelectedModule( void ) {
  180.     GT_SetGadgetAttrs( ProjectGadgets[0] , ProjectWnd , NULL , GTLV_Selected , SelectModule , TAG_DONE );
  181.     GT_SetGadgetAttrs( ProjectGadgets[0] , ProjectWnd , NULL , GTLV_Top , SelectModule , TAG_DONE );
  182. }
  183.  
  184. void UpdateNameList( void ) {
  185.   struct ModuleNode *mn=ModuleList->lh_Head;
  186.  
  187.     DettachList( );
  188.     while( mn->node.ln_Succ ) {
  189.     MakeRealNameList( mn );
  190.     mn = mn->node.ln_Succ;
  191.     }
  192.     AttachList( );
  193.     UpDateSelectedModule( );
  194. }
  195.  
  196. /****************************************************************
  197. ***    Liste des modules dans le chainage d'Exec             ***
  198. ****************************************************************/
  199.  
  200. BOOL FindName2( struct List *liste , char *search ) {
  201.   struct ModuleNode *wn=liste->lh_Head;
  202.  
  203.     while( wn->node.ln_Succ ) {
  204.     if ( !stricmp( wn->name , search ) )
  205.         return( TRUE );
  206.     wn = wn->node.ln_Succ;
  207.     }
  208.     return( FALSE );
  209. }
  210.  
  211. struct ModuleNode *AddModuleNode( struct List *list , char *name , char *directory ) {
  212.   struct ModuleNode *wn;
  213.   struct ModuleNode *bn = list->lh_TailPred;
  214.   int r;
  215.   char *t;
  216.  
  217.     if ( (wn = malloc( sizeof(struct ModuleNode) )) ) {
  218.     if ( !strchr( directory , ':' ) )
  219.         wn->directory = PathName( SourceDir , directory );
  220.     else
  221.         wn->directory = strdup( directory );
  222.     wn->pathfile = PathName( wn->directory , name );
  223.     wn->filename = BaseName( wn->pathfile );
  224.  
  225.     r = stricmp( wn->directory , SourceDir );
  226.     if ( (r && FindName2( list , wn->pathfile )) ||
  227.                 (!r && FindName2( list , wn->filename )) ) {
  228.         free( wn->directory );
  229.         free( wn->pathfile );
  230.         free( wn );
  231.         return( NULL );
  232.     }
  233.  
  234.     wn->node.ln_Type = MODULE_NODE;
  235.     if ( t = strchr( wn->filename , '.' ) )
  236.         wn->type = tolower( t[1] );
  237.     else
  238.         wn->type = 0;
  239.  
  240.     if ( list == ModuleList ) {
  241.         saved = FALSE;
  242.         MakeRealNameList( wn );
  243.     } else {
  244.         wn->node.ln_Name = wn->namelist = strdup( name );
  245.         wn->name = wn->pathfile;
  246.     }
  247.     if ( wn->type != 'l' )
  248.         while( (struct List *)bn!=list && bn->type != wn->type && bn->type != 'c' )
  249.         bn = bn->node.ln_Pred;
  250.     while( (struct List *)bn!=list && stricmp( wn->name , bn->name ) < 0 && wn->type == bn->type )
  251.         bn = bn->node.ln_Pred;
  252.     if ( (struct List *)bn!=list )
  253.         Insert( list , (struct Node *)wn , (struct Node *)bn );
  254.     else
  255.         AddHead( list , (struct Node *)wn );
  256.     return( wn );
  257.     }
  258.     return( NULL );
  259. }
  260.  
  261. /****************************************************************
  262. ***    Detruit un module dans une liste              ***
  263. ****************************************************************/
  264.  
  265. void RemModuleNode( struct ModuleNode *wn ) {
  266.  
  267.     free( wn->directory );
  268.     free( wn->pathfile );
  269.     free( wn->namelist );
  270.     Remove( (struct Node *)wn );
  271.     free( wn );
  272. }
  273.  
  274. /****************************************************************
  275. ***    Detruit tous les modules d'une list                   ***
  276. ****************************************************************/
  277.  
  278. void FreeModuleNodes( struct List *list ) {
  279.   struct ModuleNode *wn,*nn;
  280.  
  281.     wn = list->lh_Head;
  282.     while( wn->node.ln_Succ ) {
  283.     nn = wn->node.ln_Succ;
  284.     RemModuleNode( wn );
  285.     wn = nn;
  286.     }
  287. }
  288.  
  289. /****************************************************************
  290. ***    Detruit une liste ainsi que ses modules           ***
  291. ****************************************************************/
  292.  
  293. void FreeList( struct List *list ) {
  294.     FreeModuleNodes( list );
  295.     free( list );
  296. }
  297.  
  298. /****************************************************************
  299. ***    Genere une liste des fichiers include              ***
  300. ****************************************************************/
  301.  
  302. void AddIncludeList( struct List *list , struct ModuleNode *wn ) {
  303.   FILE *in;
  304.   char temp[200];
  305.   long ct=0;
  306.  
  307.     if ( wn ) {
  308.     if ( in = fopen( wn->pathfile , "r" ) ) {
  309.         while( !feof( in ) && ct < 20 ) {
  310.         fgets( temp , 200 , in );
  311.         if ( !strnicmp( temp , "#include \"" , 10 ) ) {
  312.             temp[ strlen(temp) - 2 ] = 0;
  313.             AddModuleNode( list , &temp[10] , wn->directory );
  314.             ct = 0;
  315.         }
  316.         if ( !strnicmp( temp , "#include <" , 10 ) ) {
  317.             temp[ strlen(temp) - 2 ] = 0;
  318.             AddModuleNode( list , &temp[10] , "DINCLUDE:" );
  319.             ct = 0;
  320.         }
  321.         ct++;
  322.         }
  323.         fclose( in );
  324.     }
  325.     }
  326. }
  327.  
  328. struct List *BuildIncludeList( struct ModuleNode *wn ) {
  329.   struct List *build;
  330.  
  331.     if ( build = malloc( sizeof( struct List ) ) ) {
  332.     NewList( build );
  333.     AddIncludeList( build , wn );
  334.     return( build );
  335.     }
  336.     return( NULL );
  337. }
  338.  
  339. /****************************************************************************
  340. ***                                      ***
  341. ***    Initialisation / Liberation des variables globales          ***
  342. ***                                      ***
  343. ****************************************************************************/
  344.  
  345. int InitVar( void ) {
  346.     AmigaGuideBase = OpenLibrary( "amigaguide.library" , 0L );
  347.     if ( !AmigaGuideBase )
  348.     {
  349.     ProjectNewMenu[9].nm_Flags = NM_ITEMDISABLED;
  350.     ProjectNewMenu[23].nm_Flags = NM_ITEMDISABLED;
  351.     DirSetGTags[37] = TRUE;
  352.     DirSetGTags[42] = TRUE;
  353.     }
  354.     ModuleList = malloc( sizeof( struct List ) );
  355.     if ( !ModuleList )
  356.     return( FALSE );
  357.     BuildDefScreen( NULL );
  358.     BuildScreenTags( );
  359.     CloseScreenPrefs( FALSE );
  360.     NewList( ModuleList );
  361.  
  362.     SourceDir = getcwd( NULL , 500 );
  363.     DestDir = strdup( SourceDir );
  364.     IncludeDir = PathName( SourceDir , "include" );
  365.     LibDir = PathName( SourceDir ,"dlib" );
  366.     ObjDir = strdup( SourceDir );
  367.     PrgDir = PathName( SourceDir , "bin/" );
  368.     DICEDir = strdup( SourceDir );
  369.     AutoDir = strdup( SourceDir );
  370.     MakeAssign( );
  371.     ProjectPathName = strdup( SourceDir );
  372.     ProjectName = strdup( "No Name" );
  373.     WindowTitle = strdup( "Project Handler : No Name" );
  374.     StartDir = getcwd( NULL , 500 );
  375.     OptLine = strdup( "" );
  376.     ParmsLine = strdup( "" );
  377.     MakeOptions( );
  378.     CurrentModule = NULL;
  379.     LoadPrefs( );
  380.     return( TRUE );
  381. }
  382.  
  383. void FreeVar( void ) {
  384.     FreeList( ModuleList );
  385.     DeleteScreenTags( );
  386.     RemoveAssign( );
  387.     free( DICEDir );
  388.     free( SourceDir );
  389.     free( DestDir );
  390.     free( IncludeDir );
  391.     free( LibDir );
  392.     free( ObjDir );
  393.     free( PrgDir );
  394.     free( ProjectPathName );
  395.     free( ProjectName );
  396.     free( WindowTitle );
  397.     free( StartDir );
  398.     free( OptLine );
  399.     free( ParmsLine );
  400.     CloseLibrary( AmigaGuideBase );
  401. }
  402.  
  403.  
  404. /****************************************************************************
  405. ***                                      ***
  406. ***    Action des boutons ( liste ) de la fenêtre principale             ***
  407. ***                                      ***
  408. ****************************************************************************/
  409.  
  410. int ModuleListClicked( void )
  411. {
  412.   int n = ProjectMsg.Code;
  413.   struct ModuleNode *wn = ModuleList->lh_Head;
  414.   static ULONG sec=-1,mic;
  415.  
  416.     SelectModule = n;
  417.     while( wn->node.ln_Succ && n-- ) {
  418.     wn = wn->node.ln_Succ;
  419.     }
  420.     if ( wn->node.ln_Succ )
  421.     CurrentModule = wn;
  422.  
  423.     if ( sec != -1 && DoubleClick( sec , mic , ProjectMsg.Seconds , ProjectMsg.Micros ) )
  424.     ProjectEdit( );
  425.     sec = ProjectMsg.Seconds;
  426.     mic = ProjectMsg.Micros;
  427. }
  428.  
  429.  
  430. /****************************************************************************
  431. ***                                      ***
  432. ***    Actions de gestion multitache (fermeture)                         ***
  433. ***                                      ***
  434. ****************************************************************************/
  435.  
  436. void CloseLaunchOpt( BOOL use ) {
  437.     if ( ParmsLineWnd ) {
  438.     if ( use == TRUE ) {
  439.         ReplaceChar( &ParmsLine , GetString( ParmsLineGadgets[2] ) );
  440.     }
  441.     RemWinC( ParmsLineWnd );
  442.     CloseParmsLineWindow( );
  443.     }
  444. }
  445.  
  446. int CloseEverything( void ) {
  447.     if ( handledocs )
  448.     {
  449.     SendAmigaGuideCmdA( handledocs , "QUIT" , NULL );
  450.     Delay( 10 );
  451.     CloseAmigaGuide( handledocs );
  452.     handledocs = FALSE;
  453.     }
  454.     if ( handlehelp ) {
  455.     SendAmigaGuideCmdA( handlehelp , "QUIT" ,NULL );
  456.     Delay( 10 );
  457.     CloseAmigaGuide( handlehelp );
  458.     handlehelp = FALSE;
  459.     }
  460.     ProjectCloseGenOpt( FALSE );
  461.     CloseLaunchOpt( FALSE );
  462.     CloseScreenPrefs( FALSE );
  463.     ProjectCloseCompilerOpt( FALSE );
  464.     ProjectCloseLinkerOpt( FALSE );
  465.     ProjectCloseDirSet( FALSE );
  466.     MessCloseWindow( );
  467.     RemWinC( ProjectWnd );
  468.     CloseProjectWindow( );
  469. }
  470.  
  471. /****************************************************************************
  472. ***                                      ***
  473. ***    Actions des menus de la fenêtre principale              ***
  474. ***                                      ***
  475. ****************************************************************************/
  476.  
  477. int CancelForSave( void ) {
  478.   int r=1;
  479.  
  480.     if ( !strcmp( ProjectName , "No Name" ) )
  481.     return( 0 );
  482.     while ( !saved && r==1 ) {
  483.     r = 2-Message( StrMessages[MSG_MESSAGE_SAVE] , StrMessages[MSG_MESSAGE_SAVE_ANS] );
  484.     if ( r==2 )
  485.         return( 1 );
  486.     if ( r==1 )
  487.         ProjectSave();
  488.     }
  489.     return( 0 );
  490. }
  491.  
  492. int ProjectNew( void )
  493. {
  494.     if ( !CancelForSave() ) {
  495.     DettachList( );
  496.     FreeModuleNodes( ModuleList );
  497.     ChangeProjectName( "No Name" );
  498.     saved = TRUE;
  499.     }
  500. }
  501.  
  502. int ProjectOpen( void )
  503. {
  504.   struct FileRequester *fr;
  505.   char *pf,name[200];
  506.   struct IFFHandle *iff;
  507.   struct Resource *OldScr = ProjectScreen;
  508.   struct StoredProperty *buf;
  509.   char *data,*fdata;
  510.   long w1t,w1l,w2w,w2h,w2t,w2l,w1w,w1h;
  511.  
  512.     if ( !CancelForSave() )
  513.     if ( fr = AskFile( ProjectPathName , StrMessages[MSG_MESSAGE_ASK_OPEN] , "#?.prj" ) ) {
  514.         pf = PathName( fr->rf_Dir , fr->rf_File );
  515.         if ( iff = OpenIffFile( pf , MODE_OLDFILE ) ) {
  516.         PropChunk( iff , ID_PROJ , ID_MODS );
  517.         StopOnExit( iff , ID_PROJ , ID_FORM );
  518.         if ( LoadOptions( iff ) ) {
  519.             ParseIFF( iff , IFFPARSE_SCAN );
  520.             if ( buf = FindProp( iff , ID_PROJ , ID_MODS ) ) {
  521.             FreeModuleNodes( ModuleList );
  522.             data = (char *)buf->sp_Data;
  523.             fdata = (char *)buf->sp_Data + buf->sp_Size;
  524.             while( data < fdata ) {
  525.                 AddModuleNode( ModuleList , data , data + strlen(data)+1 );
  526.                 data += strlen( data ) + 1;
  527.                 data += strlen( data ) + 1;
  528.             }
  529.             DettachList( );
  530.             w1t = ProjectTop;
  531.             w1l = ProjectLeft;
  532.             w1w = ProjectWidth;
  533.             w1h = ProjectHeight;
  534.             w2t = MessTop;
  535.             w2l = MessLeft;
  536.             w2w = MessWidth;
  537.             w2h = MessHeight;
  538.             CloseEverything( );
  539.             ProjectTop = w1t;
  540.             ProjectLeft = w1l;
  541.             ProjectWidth = w1w;
  542.             ProjectHeight = w1h;
  543.             MessTop = w2t;
  544.             MessLeft = w2l;
  545.             MessWidth = w2w;
  546.             MessHeight = w2h;
  547.             CloseDownScreen( );
  548.             SelectModule = 0;
  549.             CurrentModule = NULL;
  550.             named = TRUE;
  551.             saved = TRUE;
  552.             SetupScreen( );
  553.             OpenProjectWindow( );
  554.             AttachList( );
  555.             AddWinC( ProjectWnd , HandleProjectIDCMP );
  556.             ChangeProjectName( pf );
  557.             } else
  558.             Message( StrMessages[MSG_MESSAGE_NLOAD] , StrMessages[MSG_MESSAGE_CONTINUE] );
  559.         }
  560.         CloseIffFile( iff );
  561.         } else {
  562.         strcpy( name , StrMessages[MSG_MESSAGE_CANT] );
  563.         strcat( name , BaseName( pf ) );
  564.         Message( name , StrMessages[MSG_MESSAGE_OK] );
  565.         }
  566.         free( pf );
  567.         FreeAslRequest( fr );
  568.     }
  569. }
  570.  
  571. void SaveProject( void ) {
  572.   struct IFFHandle *iff;
  573.   struct ModuleNode *wn = (struct Node *)ModuleList->lh_Head;
  574.  
  575.     if ( iff=OpenIffFile( ProjectPathName , MODE_NEWFILE ) ) {
  576.     PushChunk( iff , ID_PROJ , ID_FORM , IFFSIZE_UNKNOWN );
  577.     SaveOptions( iff );
  578.     PushChunk( iff , ID_PROJ , ID_MODS , IFFSIZE_UNKNOWN );
  579.     while( wn->node.ln_Succ ) {
  580.         WriteChunkBytes( iff , wn->filename , strlen(wn->filename)+1 );
  581.         WriteChunkBytes( iff , wn->directory , strlen(wn->directory)+1 );
  582.         wn = wn->node.ln_Succ;
  583.     }
  584.     PopChunk( iff );
  585.     PopChunk( iff );
  586.     CloseIffFile( iff );
  587.     saved = TRUE;
  588.     }
  589. }
  590.  
  591. int ProjectSaveas( void )
  592. {
  593.   struct FileRequester *fr;
  594.   char *pf1,*pf;
  595.  
  596.     if ( fr = AskFile( ProjectPathName , StrMessages[MSG_MESSAGE_ASK_SAVE] , "#?.prj" ) ) {
  597.     pf1 = PathName( fr->rf_Dir , fr->rf_File );
  598.     pf = malloc( strlen( pf1 ) + 5 );
  599.     strcpy( pf , pf1 );
  600.     if ( stricmp( ".prj" , &pf1[ strlen( pf1 ) - 4 ] ) )
  601.         strcat( pf , ".prj" );
  602.     if ( Overwrite( "project" , pf ) ) {
  603.         ChangeProjectName( pf );
  604.         SaveProject( );
  605.         named = TRUE;
  606.     } else
  607.         free( pf );
  608.     FreeAslRequest( fr );
  609.     }
  610. }
  611.  
  612. int ProjectSave( void )
  613. {
  614.     if ( !named ) {
  615.     ProjectSaveas( );
  616.     }
  617.     SaveProject( );
  618. }
  619.  
  620. /* Iconification : Ne marche pas pour l'instant ????? */
  621.  
  622.  
  623. int ProjectIcon( void )
  624. {
  625.   struct AppMessage *appmsg=NULL;
  626.   static struct MsgPort    *iconport=NULL;
  627.   static struct AppIcon    *appicon=NULL;
  628.   static struct DiskObject *dobj=NULL;
  629.  
  630.     if ( dobj = GetDiskObject( "Work:DICE/Project030" ) ) {
  631.     dobj->do_Type = NULL;
  632.     dobj->do_CurrentX = NO_ICON_POSITION;
  633.     dobj->do_CurrentY = NO_ICON_POSITION;
  634.     if ( iconport = CreateMsgPort() ) {
  635.         MessCloseWindow( );
  636.         CloseProjectWindow( );
  637.         CloseDownScreen( );
  638.         if ( appicon = AddAppIconA( 0 , 0L , "Project_Handler" , iconport , NULL , dobj , NULL ) ) {
  639.         WaitPort( iconport );
  640.         RemoveAppIcon( appicon );
  641.         }
  642.         DisplayBeep( NULL );
  643.         while( appmsg=(struct AppMessage *)GetMsg( iconport ) )
  644.         ReplyMsg( (struct Message *)appmsg );
  645.         DeleteMsgPort( iconport );
  646.         SetupScreen( );
  647.         OpenProjectWindow( );
  648.         ChangeProjectName( ProjectPathName );
  649.         AttachList( );
  650.         UpDateSelectedModule( );
  651.     }
  652.     FreeDiskObject( dobj );
  653.     }
  654. }
  655.  
  656. int ProjectAbout( void )
  657. {
  658.     Message( "Project Handler 1.2 ( April 2, 1993 )\n\n"
  659.          "© Copyright 1993 Arcad Development\n"
  660.          " Written using DICE C v2.07.54R by\n"
  661.          "         Cedric Counotte\n\n"
  662.          " Thanks to Jan van den Baard\n"
  663.          "     for GadToolsBox 37.176\n"
  664.         , "Continue" );
  665. }
  666.  
  667. void ChargeAide( char *node )
  668. {
  669.   char *t;
  670.  
  671.     t = malloc( strlen(node)+8 );
  672.     strcpy( t , "LINK " );
  673.     strcat( t , node );
  674.     if ( AmigaGuideBase )
  675.     {
  676.     if ( !handlehelp )
  677.     {
  678.         aghelp.nag_Screen = Scr;
  679.         handlehelp = OpenAmigaGuideAsyncA( &aghelp , NULL );
  680.         Delay( 10 );
  681.         SetAmigaGuideAttrs( handlehelp , AGA_Activate , TRUE , TAG_DONE );
  682.     }
  683.     if ( handlehelp )
  684.         SendAmigaGuideCmdA( handlehelp , t ,NULL );
  685.     }
  686.     else
  687.     Message( StrMessages[MSG_MESSAGE_NOGUIDE] , StrMessages[MSG_MESSAGE_ABORT] );
  688.     free( t );
  689. }
  690.  
  691. int ProjectHelp( void )
  692. {
  693.     ChargeAide( "Main" );
  694. }
  695.  
  696. int ProjectQuit( void )
  697. {
  698.     if ( !CancelForSave() ) {
  699.     CloseEverything( );
  700.     }
  701. }
  702.  
  703. int ProjectEdit( void )
  704. {
  705.     if ( CurrentModule ) {
  706.     EditModule( CurrentModule->pathfile );
  707.     }
  708. }
  709.  
  710. int ProjectInclude( void )
  711. {
  712.   struct List *IncludeList;
  713.   struct ModuleNode *include;
  714.  
  715.     if ( CurrentModule ) {
  716.     if ( IncludeList = BuildIncludeList( CurrentModule ) ) {
  717.         if ( IncludeList->lh_Head->ln_Succ ) {
  718.         include = (struct ModuleNode *)ChooseInList( StrMessages[MSG_WIN_INCLUDE_TITLE] , IncludeList , 300 , 200 );
  719.         if ( include )
  720.             EditModule( include->pathfile );
  721.         }
  722.         FreeList( IncludeList );
  723.     }
  724.     }
  725. }
  726.  
  727. int ProjectComment( void )
  728. {
  729.   struct FileInfoBlock fib;
  730.   char *commentfile;
  731.  
  732.     if ( CurrentModule ) {
  733.     if ( CurrentModule->filename[ strlen(CurrentModule->filename)-1 ] == 'c' ) {
  734.         commentfile = CommentName( CurrentModule->pathfile );
  735.         if ( !GetInfo( &fib , commentfile ) )
  736.         if ( !Message( StrMessages[MSG_MESSAGE_NOCOMMENT] , StrMessages[MSG_MESSAGE_NOCOMMENT_ANS] ) ) {
  737.             free( commentfile );
  738.             return( 0 );
  739.         }
  740.         EditModule( commentfile );
  741.         DettachList( );
  742.         MakeRealNameList( CurrentModule );
  743.         AttachList( );
  744.         UpDateSelectedModule( );
  745.         free( commentfile );
  746.     } else
  747.         Message( StrMessages[MSG_MESSAGE_NOTONC] , StrMessages[MSG_MESSAGE_CONTINUE] );
  748.     }
  749. }
  750.  
  751. int ProjectCommentKill( void )
  752. {
  753.   char *commentfile,mess[200];
  754.  
  755.     if ( CurrentModule ) {
  756.     if ( CurrentModule->filename[ strlen(CurrentModule->filename)-1 ] == 'c' ) {
  757.         commentfile = CommentName( CurrentModule->pathfile );
  758.         if ( IsCommented( CurrentModule->pathfile ) ) {
  759.         strcpy( mess , StrMessages[MSG_MESSAGE_BINDED1] );
  760.         strcat( mess , CurrentModule->filename );
  761.         strcat( mess , StrMessages[MSG_MESSAGE_BINDED2] );
  762.         if ( Message( mess , StrMessages[MSG_MESSAGE_BINDED_ANS] ) ) {
  763.             DeleteFile( commentfile );
  764.             DettachList( );
  765.             MakeRealNameList( CurrentModule );
  766.             AttachList( );
  767.             UpDateSelectedModule( );
  768.         }
  769.         } else
  770.         Message( StrMessages[MSG_MESSAGE_DONT_OWNED] , StrMessages[MSG_MESSAGE_CONTINUE] );
  771.         free( commentfile );
  772.     } else
  773.         Message( StrMessages[MSG_MESSAGE_CANT_OWNED] , StrMessages[MSG_MESSAGE_CONTINUE] );
  774.     }
  775. }
  776.  
  777. int ProjectAdd( void )
  778. {
  779.   struct FileRequester *fr;
  780.   struct Node *wn = ModuleList->lh_Head;
  781.  
  782.     if (fr = AskFile( SourceDir , StrMessages[MSG_MESSAGE_ADD_MOD] , "(#?.a|#?.c|#?.o|#?.lib)" )) {
  783.     DettachList( );
  784.     CurrentModule = AddModuleNode( ModuleList , fr->rf_File , fr->rf_Dir );
  785.     SelectModule = 0;
  786.     AttachList( );
  787.     if ( CurrentModule ) {
  788.         while( wn->ln_Succ && wn!=(struct Node *)CurrentModule ) {
  789.         wn = wn->ln_Succ;
  790.         SelectModule ++;
  791.         }
  792.         UpDateSelectedModule( );
  793.     }
  794.     FreeAslRequest(fr);
  795.     }
  796. }
  797.  
  798. int ProjectRem( void )
  799. {
  800.     if ( CurrentModule ) {
  801.     DettachList( );
  802.     RemModuleNode( CurrentModule );
  803.     saved = FALSE;
  804.     AttachList( );
  805.     CurrentModule = NULL;
  806.     }
  807. }
  808.  
  809. int ProjectOther( void )
  810. {
  811.   struct FileRequester *fr;
  812.   char *buf;
  813.  
  814.     if ( fr = AskFile( SourceDir, StrMessages[MSG_MESSAGE_OTHER] , "#?(.a|.c|.h)" ) ) {
  815.     buf = PathName( fr->rf_Dir , fr->rf_File );
  816.     EditModule( buf );
  817.     free( buf );
  818.     FreeAslRequest( fr );
  819.     }
  820. }
  821.  
  822. int ProjectAutoDocs( void )
  823. {
  824.   struct Liste *Docs;
  825.   struct ModuleNode *autodoc;
  826.   struct ExAllControl *eac;
  827.   BPTR lock;
  828.   BOOL more;
  829.   char Data[200];
  830.   struct ExAllData *ead;
  831.  
  832.     if ( eac = AllocDosObject( DOS_EXALLCONTROL, NULL ) )
  833.     {
  834.     if ( lock = Lock( AutoDir , ACCESS_READ ) )
  835.     {
  836.         if ( Docs = malloc( sizeof( struct List ) ) )
  837.         {
  838.         NewList( Docs );
  839.         eac->eac_LastKey = 0;
  840.         do {
  841.             more = ExAll( lock , (APTR)Data , 200 , ED_NAME , eac );
  842.             ead = (struct ExAllData *)Data;
  843.             while( ead->ed_Next )
  844.             {
  845.             if ( stricmp( &ead->ed_Name[strlen(ead->ed_Name)-5] , ".info" ) )
  846.                 AddModuleNode( Docs , ead->ed_Name , AutoDir );
  847.             ead = ead->ed_Next;
  848.             }
  849.         } while ( more );
  850.         autodoc = (struct ModuleNode *)ChooseInList( StrMessages[MSG_MESSAGE_AUTODOC] , Docs , 300 , 200 );
  851.         if ( autodoc )
  852.         {
  853.             if ( handledocs )
  854.             SendAmigaGuideCmdA( handledocs , "Quit" , NULL );
  855.             agdocs.nag_Name = autodoc->pathfile;
  856.             agdocs.nag_Screen = Scr;
  857.             handledocs = OpenAmigaGuideAsyncA( &agdocs , NULL );
  858.             Delay( 10 );
  859.             SendAmigaGuideCmdA( handledocs , "ALINK Main" , NULL );
  860.         }
  861.         FreeList( Docs );
  862.         }
  863.         UnLock( lock );
  864.     }
  865.     FreeDosObject( DOS_EXALLCONTROL , eac );
  866.     }
  867. }
  868.  
  869. int CheckDependencies( struct ModuleNode *wn ) {
  870.   char *obj;
  871.   struct FileInfoBlock fib1,fib2;
  872.   struct List *includes;
  873.   BOOL ret;
  874.  
  875.     CompileRender( "Checking dependencies." );
  876.     obj = MakeObjectPath( wn->filename );
  877.     ret = !GetInfo( &fib1 , obj );
  878.     free( obj );
  879.  
  880.     if ( !ret && GetInfo( &fib2 , wn->pathfile ) )
  881.     if ( CompareDates( &fib1.fib_Date , &fib2.fib_Date ) > 0 )
  882.         ret = TRUE;
  883.     if ( !ret ) {
  884.     includes = BuildIncludeList( wn );
  885.     wn = includes->lh_Head;
  886.     while( wn->node.ln_Succ ) {
  887.         if ( GetInfo( &fib2 , wn->pathfile ) )
  888.         if ( CompareDates( &fib1.fib_Date , &fib2.fib_Date ) > 0 )
  889.             ret = TRUE;
  890.         wn = wn->node.ln_Succ;
  891.     }
  892.     FreeList( includes );
  893.     }
  894.     CompileRender( "Compiler processing..." );
  895.     return( ret );
  896. }
  897.  
  898. void DeleteObjects( void ) {
  899.   char *temp;
  900.   struct ModuleNode *wn = ModuleList->lh_Head;
  901.  
  902.     while( wn->node.ln_Succ ) {
  903.     temp = MakeObjectPath( wn->filename );
  904.     DeleteFile( temp );
  905.     free( temp );
  906.     wn = wn->node.ln_Succ;
  907.     }
  908.     compilall = FALSE;
  909. }
  910.  
  911. int ProjectCompile( void )
  912. {
  913.   char command[500];
  914.   struct ModuleNode *wn = ModuleList->lh_Head;
  915.   struct IntuiMessage *m=NULL;
  916.   BOOL ret=TRUE;
  917.  
  918.     SleepWinC( );
  919.     if ( compilall )
  920.     DeleteObjects( );
  921.     KeepMessages = FALSE;
  922.     OpenCompileWindow( "Compiler processing..." );
  923.     chdir( ObjDir );
  924.     while( wn->node.ln_Succ ) {
  925.     if ( wn->type == 'c' ) {
  926.         GT_SetGadgetAttrs( CompileGadgets[0] , CompileWnd , NULL , GTTX_Text , (long)wn->name , TAG_DONE );
  927.         if ( CheckDependencies( wn ) ) {
  928.         link = TRUE;
  929.         strcpy( command , PrgDir );
  930.         strcat( command , "dcc >RAM:Compiler_Error -c " );
  931.         strcat( command , wn->pathfile );
  932.         strcat( command , " -o \"" );
  933.         strcat( command , wn->filename );
  934.         command[ strlen(command)-1 ] = 'o';
  935.         strcat( command , "\" -E \"ram:Compiler_Errors\"" );
  936.         strcat( command , OptLine );
  937.         DeleteFile( "RAM:Compiler_Errors" );
  938.         DeleteFile( "RAM:Compiler_Error" );
  939.         Launch( command , FALSE );
  940.         if ( ViewErrors( "RAM:Compiler_Errors" ) )
  941.         {
  942.             ret = FALSE;
  943.             break;
  944.         }
  945.         }
  946.         if ( (m = GT_GetIMsg( CompileWnd->UserPort )) )
  947.         {
  948.         ret = FALSE;
  949.         break;
  950.         }
  951.     }
  952.     wn = wn->node.ln_Succ;
  953.     }
  954.     if ( m )
  955.     GT_ReplyIMsg( m );
  956.     chdir( StartDir );
  957.     CloseCompileWindow( );
  958.     UpdateNameList( );
  959.     AwakeWinC( );
  960.     return( ret );
  961. }
  962.  
  963. void CreateObjList( void ) {
  964.   struct ModuleNode *wn = ModuleList->lh_Head;
  965.   FILE *out;
  966.   char *buf;
  967.  
  968.     if ( out = fopen( "ram:objlist" , "w" ) ) {
  969.     while( wn->node.ln_Succ ) {
  970.         buf = strdup( wn->pathfile );
  971.         if ( wn->type == 'c' ) {
  972.         free( buf );
  973.         buf = MakeObjectPath( wn->filename );
  974.         }
  975.         OutputString( buf , out );
  976.         free( buf );
  977.         wn = wn->node.ln_Succ;
  978.     }
  979.     fclose( out );
  980.     }
  981. }
  982.  
  983. int ProjectGenerate( void )
  984. {
  985.     DeleteObjects( );
  986.     ProjectCompile( );
  987.     link = TRUE;
  988. }
  989.  
  990. int ProjectLink( void )
  991. {
  992.   char *command;
  993.  
  994.     OpenCompileWindow( "Linker processing..." );
  995.     CreateObjList( );
  996.     chdir( DestDir );
  997.     command = malloc( strlen(PrgDir)+strlen(ProjectName)+strlen(OptLine)+70 );
  998.     strcpy( command , PrgDir );
  999.     strcat( command , "dcc >\"RAM:Linker_Error\" @RAM:objlist -E \"RAM:Linker_Errors\" -o \"" );
  1000.     strcat( command , ProjectName );
  1001.     strcat( command , "\"" );
  1002.     strcat( command , OptLine );
  1003.     DeleteFile( "RAM:Linker_Errors" );
  1004.     DeleteFile( "RAM:Linker_Error" );
  1005.     Launch( command , FALSE );
  1006.     free( command );
  1007.     chdir( StartDir );
  1008.     CloseCompileWindow( );
  1009.     if ( !ViewErrors( "RAM:Linker_Errors" ) ) {
  1010.     link = FALSE;
  1011.     return( TRUE );
  1012.     }
  1013.     return( FALSE );
  1014. }
  1015.  
  1016. int ProjectLibrary( void )
  1017. {
  1018.   char *command;
  1019.  
  1020.     OpenCompileWindow( "Library Maker processing..." );
  1021.     CreateObjList( );
  1022.     chdir( DestDir );
  1023.     command = malloc( strlen(ProjectName)+50+strlen(PrgDir) );
  1024.     strcat( command , ProjectName );
  1025.     strcat( command , ".lib" );
  1026.     DeleteFile( command );
  1027.     strcpy( command , PrgDir );
  1028.     strcat( command , "libmake RAM:objlist -mRR -proto -o ram: -l \"" );
  1029.     strcat( command , ProjectName );
  1030.     strcat( command , ".lib\"" );
  1031.     Launch( command , FALSE );
  1032.     free( command );
  1033.     chdir( StartDir );
  1034.     CloseCompileWindow( );
  1035. }
  1036.  
  1037. int ProjectMakeFO( void )
  1038. {
  1039.     if ( ProjectCompile( ) )
  1040.     {
  1041.     SleepWinC( );
  1042.     switch( Config.ObjType )
  1043.     {
  1044.       case 0:
  1045.         ProjectLink( );
  1046.         break;
  1047.       case 1:
  1048.         ProjectLibrary( );
  1049.         break;
  1050.       case 2:
  1051.         Message( "This kind of Final Object is not implemented!","Continue" );
  1052.         break;
  1053.     }
  1054.     AwakeWinC( );
  1055.     }
  1056. }
  1057.  
  1058. int ProjectCodeInfo( void )
  1059. {
  1060.   struct FileInfoBlock fib;
  1061.   char mess[500];
  1062.   struct DateTime *dt;
  1063.  
  1064.     chdir( DestDir );
  1065.     if ( GetInfo( &fib , ProjectName ) ) {
  1066.     strcpy( mess , StrMessages[MSG_MESSAGE_PROJECTNAME] );
  1067.     strcat( mess , " : " );
  1068.     strcat( mess , ProjectName );
  1069.     strcat( mess , "\n\n" );
  1070.     strcat( mess , StrMessages[MSG_MESSAGE_EXECUTABLE] );
  1071.     strcat( mess , " : " );
  1072.     ltoa( &mess[ strlen(mess) ] , fib.fib_Size );
  1073.     strcat( mess , "\n\n" );
  1074.     strcat( mess , StrMessages[MSG_MESSAGE_DATE] );
  1075.     strcat( mess , " : " );
  1076.     if ( dt = GetDate( &fib ) ) {
  1077.         strcat( mess , dt->dat_StrDay );
  1078.         strcat( mess , " " );
  1079.         strcat( mess , dt->dat_StrDate );
  1080.         strcat( mess , "\n" );
  1081.         strcat( mess , StrMessages[MSG_MESSAGE_TIME] );
  1082.         strcat( mess , " : " );
  1083.         strcat( mess , dt->dat_StrTime );
  1084.     }
  1085.     strcat( mess , "\n\n" );
  1086.     Message( mess , StrMessages[MSG_MESSAGE_CONTINUE] );
  1087.     } else
  1088.     Message( StrMessages[MSG_MESSAGE_GENERATE] , StrMessages[MSG_MESSAGE_CONTINUE] );
  1089.     chdir( StartDir );
  1090. }
  1091.  
  1092. int ProjectLaunch( void )
  1093. {
  1094.   char *command;
  1095.   char *cmd;
  1096.  
  1097.     if ( link )
  1098.     if ( !ProjectLink( ) )
  1099.         return( 0 );
  1100.     command = PathName( DestDir , ProjectName );
  1101.     cmd = malloc( strlen( command ) + strlen( ParmsLine ) + 2 );
  1102.     strcpy( cmd , command );
  1103.     strcat( cmd , " " );
  1104.     strcat( cmd , ParmsLine );
  1105.     Launch( cmd , TRUE );
  1106.     free( command );
  1107.     free( cmd );
  1108. }
  1109.  
  1110. void ProjectLaunchOptCommand( void ) {
  1111.   struct IntuiMessage *m;
  1112.  
  1113.     while( (ParmsLineWnd != NULL) && (m = GT_GetIMsg( ParmsLineWnd->UserPort )) ) {
  1114.     GT_ReplyIMsg( m );
  1115.     switch ( m->Class ) {
  1116.       case IDCMP_REFRESHWINDOW:
  1117.         GT_BeginRefresh( ParmsLineWnd );
  1118.         GT_EndRefresh( ParmsLineWnd, TRUE );
  1119.         break;
  1120.       case IDCMP_VANILLAKEY:
  1121.         switch( m->Code ) {
  1122.           case 13:
  1123.           case 'e':
  1124.           case 'E':
  1125.         ActivateGadget( ParmsLineGadgets[2] , ParmsLineWnd , NULL );
  1126.         break;
  1127.           case 'u':
  1128.           case 'U':
  1129.         CloseLaunchOpt( TRUE );
  1130.         break;
  1131.           case 'a':
  1132.           case 'A':
  1133.         CloseLaunchOpt( FALSE );
  1134.         break;
  1135.         }
  1136.         break;
  1137.       case IDCMP_RAWKEY:
  1138.         if ( m->Code == 95 )
  1139.         ChargeAide( "WIN_Parms" );
  1140.         break;
  1141.       case IDCMP_GADGETUP:
  1142.         switch( ((struct Gadget *)m->IAddress)->GadgetID ) {
  1143.           case 1:
  1144.         CloseLaunchOpt( TRUE );
  1145.         break;
  1146.           case 2:
  1147.         CloseLaunchOpt( FALSE );
  1148.         break;
  1149.         }
  1150.         break;
  1151.     }
  1152.     }
  1153. }
  1154.  
  1155. int ProjectLaunchOpt( void )
  1156. {
  1157.     if ( !ParmsLineWnd )
  1158.     if ( !OpenParmsLineWindow() )
  1159.     {
  1160.         GT_SetGadgetAttrs( ParmsLineGadgets[2] , ParmsLineWnd , NULL , GTST_String , ParmsLine , TAG_DONE );
  1161.         AddWinC( ParmsLineWnd , ProjectLaunchOptCommand );
  1162.     }
  1163.     else {
  1164.     WindowToFront( ParmsLineWnd );
  1165.     ActivateWindow( ParmsLineWnd );
  1166.     }
  1167. }
  1168.  
  1169. /****************************************************************************
  1170. ***                                      ***
  1171. ***    Actions des messages VANILLAKEY                   ***
  1172. ***                                      ***
  1173. ****************************************************************************/
  1174.  
  1175. void NextModule( void ) {
  1176.     if ( !CurrentModule ) {
  1177.     CurrentModule = ModuleList->lh_Head;
  1178.     SelectModule = 0;
  1179.     } else {
  1180.     if ( CurrentModule->node.ln_Succ->ln_Succ ) {
  1181.         CurrentModule = CurrentModule->node.ln_Succ;
  1182.         SelectModule ++;
  1183.     }
  1184.     }
  1185.     UpDateSelectedModule( );
  1186. }
  1187.  
  1188. void PrevModule( void ) {
  1189.     if ( !CurrentModule ) {
  1190.     CurrentModule = ModuleList->lh_Head;
  1191.     SelectModule = 0;
  1192.     while( CurrentModule->node.ln_Succ->ln_Succ ) {
  1193.         CurrentModule = CurrentModule->node.ln_Succ;
  1194.         SelectModule ++;
  1195.     }
  1196.     } else {
  1197.     if ( CurrentModule->node.ln_Pred->ln_Pred ) {
  1198.         CurrentModule = CurrentModule->node.ln_Pred;
  1199.         SelectModule --;
  1200.     }
  1201.     }
  1202.     UpDateSelectedModule( );
  1203. }
  1204.  
  1205. void FindSelectedModule( long letter ) {
  1206.   struct ModuleNode *wn = ModuleList->lh_Head;
  1207.   BOOL found = FALSE;
  1208.   long select=0;
  1209.  
  1210.     while( wn->node.ln_Succ && !found ) {
  1211.     if ( tolower(*wn->name) == letter ) {
  1212.         found = TRUE;
  1213.         break;
  1214.     }
  1215.     select++;
  1216.     wn = wn->node.ln_Succ;
  1217.     }
  1218.     if ( found ) {
  1219.     CurrentModule = wn;
  1220.     SelectModule = select;
  1221.     UpDateSelectedModule( );
  1222.     }
  1223. }
  1224.  
  1225. /****************************************************************************
  1226. ***                                      ***
  1227. ***    Actions des messages IDCMP                      ***
  1228. ***                                      ***
  1229. ****************************************************************************/
  1230.  
  1231. int ProjectCloseWindow( void )
  1232. {
  1233.     ProjectQuit( );
  1234. }
  1235.  
  1236. int ProjectNewSize( void )
  1237. {
  1238.     DettachList( );
  1239.  
  1240.     RemWinC( ProjectWnd );
  1241.     CloseProjectWindow( );
  1242.     OpenProjectWindow( );
  1243.     AddWinC( ProjectWnd , HandleProjectIDCMP );
  1244.     ChangeProjectName( ProjectPathName );
  1245.     if ( named )
  1246.     saved = FALSE;
  1247.  
  1248.     AttachList( );
  1249.     UpDateSelectedModule( );
  1250. }
  1251.  
  1252. int ProjectCloseWB( void )
  1253. {
  1254.   BOOL rr;
  1255.  
  1256.     while( rr && !CloseWorkBench() ) {
  1257.     rr = Message( StrMessages[MSG_MESSAGE_CANT_CLOSEWB] , StrMessages[MSG_MESSAGE_RETRY_ABORT] );
  1258.     }
  1259. }
  1260.  
  1261. int ProjectOpenWB( void )
  1262. {
  1263.     OpenWorkBench();
  1264. }
  1265.  
  1266.  
  1267.  
  1268. /****************************************************************************
  1269. ***                                      ***
  1270. ***    Fonctions de localisation                      ***
  1271. ***                                      ***
  1272. ****************************************************************************/
  1273.  
  1274.  
  1275. void GetMenu(void)
  1276. {
  1277.   struct NewMenu *nm = ProjectNewMenu;
  1278.   long i=MSG_MENU_PROJECT;
  1279.  
  1280.     while( nm->nm_Type )
  1281.     {
  1282.     while( nm->nm_Label == NM_BARLABEL )
  1283.         nm++;
  1284.     nm->nm_Label = GetCatalogStr( Catalog , i++ , nm->nm_Label );
  1285.     nm++;
  1286.     }
  1287. }
  1288.  
  1289. void GetUseCancel(void)
  1290. {
  1291.     CompilerNGad[13].ng_GadgetText =
  1292.     LinkerNGad[0].ng_GadgetText =
  1293.     DirSetNGad[14].ng_GadgetText =
  1294.     GenOptNGad[3].ng_GadgetText =
  1295.     ScreenPrefsNGad[1].ng_GadgetText =
  1296.     PalettePrefsNGad[6].ng_GadgetText =
  1297.     ParmsLineNGad[0].ng_GadgetText =
  1298.         GetCatalogStr( Catalog , MSG_USE , "_Use" );
  1299.     CompilerNGad[14].ng_GadgetText =
  1300.     LinkerNGad[1].ng_GadgetText =
  1301.     DirSetNGad[15].ng_GadgetText =
  1302.     GenOptNGad[4].ng_GadgetText =
  1303.     ScreenPrefsNGad[2].ng_GadgetText =
  1304.     PalettePrefsNGad[7].ng_GadgetText =
  1305.     ParmsLineNGad[1].ng_GadgetText =
  1306.         GetCatalogStr( Catalog , MSG_CANCEL , "C_ancel" );
  1307. }
  1308.  
  1309. void MakeUseCancel(void)
  1310. {
  1311.     CompilerNGad[13].ng_GadgetText =
  1312.     LinkerNGad[0].ng_GadgetText =
  1313.     DirSetNGad[14].ng_GadgetText =
  1314.     GenOptNGad[3].ng_GadgetText =
  1315.     ScreenPrefsNGad[1].ng_GadgetText =
  1316.     PalettePrefsNGad[6].ng_GadgetText =
  1317.     ParmsLineNGad[0].ng_GadgetText =
  1318.         "_Use";
  1319.     CompilerNGad[14].ng_GadgetText =
  1320.     LinkerNGad[1].ng_GadgetText =
  1321.     DirSetNGad[15].ng_GadgetText =
  1322.     GenOptNGad[4].ng_GadgetText =
  1323.     ScreenPrefsNGad[2].ng_GadgetText =
  1324.     PalettePrefsNGad[7].ng_GadgetText =
  1325.     ParmsLineNGad[1].ng_GadgetText =
  1326.         "C_ancel";
  1327. }
  1328.  
  1329. void GetTitles(void)
  1330. {
  1331.     ProjectWdt = GetCatalogStr( Catalog , MSG_WIN_TITLE_SOURCE , ProjectWdt );
  1332.     DirSetWdt = GetCatalogStr( Catalog , MSG_WIN_TITLE_DIRSET , DirSetWdt );
  1333.     MessWdt = GetCatalogStr( Catalog , MSG_WIN_TITLE_MESS , MessWdt );
  1334.     GenOptWdt = GetCatalogStr( Catalog , MSG_WIN_TITLE_GENERAL , GenOptWdt );
  1335.     ParmsLineWdt = GetCatalogStr( Catalog , MSG_WIN_TITLE_PARMCLI , ParmsLineWdt );
  1336.     CompilerWdt = GetCatalogStr( Catalog , MSG_WIN_TITLE_COMPILER , CompilerWdt );
  1337.     LinkerWdt = GetCatalogStr( Catalog , MSG_WIN_TITLE_LINKER , LinkerWdt );
  1338.     CompileWdt = GetCatalogStr( Catalog , MSG_WIN_TITLE_PROCESS , CompileWdt );
  1339.     ScreenPrefsWdt = GetCatalogStr( Catalog , MSG_WIN_TITLE_SCREEN_PREF , ScreenPrefsWdt );
  1340.     PalettePrefsWdt = GetCatalogStr( Catalog , MSG_WIN_TITLE_PALETTE_PREF , PalettePrefsWdt );
  1341. }
  1342.  
  1343. void GetCompilerWnd( void )
  1344. {
  1345.   int n = MSG_WIN_COMPILER_DIVERS_INLINE;
  1346.  
  1347.     CompilerIText[0].IText = GetCatalogStr( Catalog , MSG_WIN_COMPILER_GENERATION , CompilerIText[0].IText );
  1348.     CompilerIText[1].IText = GetCatalogStr( Catalog , MSG_WIN_COMPILER_CMODEL , CompilerIText[1].IText );
  1349.     CompilerIText[2].IText = GetCatalogStr( Catalog , MSG_WIN_COMPILER_DMODEL , CompilerIText[2].IText );
  1350.     CompilerIText[3].IText = GetCatalogStr( Catalog , MSG_WIN_COMPILER_PROCCALL , CompilerIText[3].IText );
  1351.     CompilerIText[4].IText = GetCatalogStr( Catalog , MSG_WIN_COMPILER_CTEHUNK , CompilerIText[4].IText );
  1352.     CompilerIText[5].IText = GetCatalogStr( Catalog , MSG_WIN_COMPILER_PROFILE , CompilerIText[5].IText );
  1353.     CompilerIText[6].IText = GetCatalogStr( Catalog , MSG_WIN_COMPILER_DIVERS , CompilerIText[6].IText );
  1354.  
  1355.     FPU0Labels[0] = GetCatalogStr( Catalog , MSG_WIN_COMPILER_None , FPU0Labels[0] );
  1356.     Code0Labels[0] = GetCatalogStr( Catalog , MSG_WIN_COMPILER_CSMALL , Code0Labels[0] );
  1357.     Code0Labels[1] = GetCatalogStr( Catalog , MSG_WIN_COMPILER_CLARGE , Code0Labels[1] );
  1358.     Data0Labels[0] = GetCatalogStr( Catalog , MSG_WIN_COMPILER_DSMALL , Data0Labels[0] );
  1359.     Data0Labels[1] = GetCatalogStr( Catalog , MSG_WIN_COMPILER_DLARGE , Data0Labels[1] );
  1360.     Calls0Labels[0] = GetCatalogStr( Catalog , MSG_WIN_COMPILER_REGISTER , Calls0Labels[0] );
  1361.     Calls0Labels[1] = GetCatalogStr( Catalog , MSG_WIN_COMPILER_TRSTACK , Calls0Labels[1] );
  1362.     HunkCode0Labels[0] = GetCatalogStr( Catalog , MSG_WIN_COMPILER_ONLYCTE , HunkCode0Labels[0] );
  1363.     HunkCode0Labels[1] = GetCatalogStr( Catalog , MSG_WIN_COMPILER_BOTHCS , HunkCode0Labels[1] );
  1364.     HunkCode0Labels[2] = GetCatalogStr( Catalog , MSG_WIN_COMPILER_ALLCTE , HunkCode0Labels[2] );
  1365.     Profile0Labels[0] = GetCatalogStr( Catalog , MSG_WIN_COMPILER_PROFILE_DISABLE , Profile0Labels[0] );
  1366.     Profile0Labels[1] = GetCatalogStr( Catalog , MSG_WIN_COMPILER_PROFILE_CODE , Profile0Labels[1] );
  1367.     Profile0Labels[2] = GetCatalogStr( Catalog , MSG_WIN_COMPILER_PROFILE_ALL , Profile0Labels[2] );
  1368.  
  1369.     while( n <= MSG_WIN_COMPILER_DIVERS_DLEVEL )
  1370.     {
  1371.     CompilerNGad[ n - MSG_WIN_COMPILER_GENERATION - 14 ].ng_GadgetText = GetCatalogStr( Catalog , n , CompilerNGad[ n - MSG_WIN_COMPILER_GENERATION - 14 ].ng_GadgetText );
  1372.     n++;
  1373.     }
  1374. }
  1375.  
  1376. void GetDirWnd( void )
  1377. {
  1378.     DirSetNGad[0].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_DIR_SOURCE , DirSetNGad[0].ng_GadgetText );
  1379.     DirSetNGad[1].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_DIR_DEST , DirSetNGad[1].ng_GadgetText );
  1380.     DirSetNGad[2].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_DIR_INCLUDE , DirSetNGad[2].ng_GadgetText );
  1381.     DirSetNGad[3].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_DIR_LIB , DirSetNGad[3].ng_GadgetText );
  1382.     DirSetNGad[4].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_DIR_OBJ , DirSetNGad[4].ng_GadgetText );
  1383.     DirSetNGad[12].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_DIR_AUTO , DirSetNGad[12].ng_GadgetText );
  1384. }
  1385.  
  1386. void GetLinkerWnd( void )
  1387. {
  1388.   int n = MSG_WIN_LINKER_CHIP;
  1389.  
  1390.     while ( n <= MSG_WIN_LINKER_UNIX )
  1391.     {
  1392.     LinkerNGad[ n - MSG_WIN_LINKER_CHIP + 2 ].ng_GadgetText = GetCatalogStr( Catalog , n , LinkerNGad[ n - MSG_WIN_LINKER_CHIP + 2 ].ng_GadgetText );
  1393.     n++;
  1394.     }
  1395. }
  1396.  
  1397. void GetGenOptWnd( void )
  1398. {
  1399.     Type1Labels[0] = GetCatalogStr( Catalog , MSG_WIN_GENERAL_EXECUTABLE , Type1Labels[0] );
  1400.     Type1Labels[1] = GetCatalogStr( Catalog , MSG_WIN_GENERAL_LIBRARY , Type1Labels[1] );
  1401.     Type1Labels[2] = GetCatalogStr( Catalog , MSG_WIN_GENERAL_ROMABLE , Type1Labels[2] );
  1402.     GenOptNGad[0].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_GENERAL_FOTYPE , GenOptNGad[0].ng_GadgetText );
  1403.     GenOptNGad[1].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_GENERAL_OSVER , GenOptNGad[1].ng_GadgetText );
  1404.     GenOptNGad[2].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_GENERAL_OSREV , GenOptNGad[2].ng_GadgetText );
  1405. }
  1406.  
  1407. void GetPaletteWnd( void )
  1408. {
  1409.     PalettePrefsNGad[0].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_PALETTE_PEN , PalettePrefsNGad[0].ng_GadgetText );
  1410.     PalettePrefsNGad[2].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_PALETTE_COLORS , PalettePrefsNGad[2].ng_GadgetText );
  1411.     PalettePrefsNGad[3].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_PALETTE_RED , PalettePrefsNGad[3].ng_GadgetText );
  1412.     PalettePrefsNGad[4].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_PALETTE_GREEN , PalettePrefsNGad[4].ng_GadgetText );
  1413.     PalettePrefsNGad[5].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_PALETTE_BLUE , PalettePrefsNGad[5].ng_GadgetText );
  1414.     Pens1Nodes[0].ln_Name = GetCatalogStr( Catalog , MSG_WIN_PALETTE_BLOCK , Pens1Nodes[0].ln_Name );
  1415.     Pens1Nodes[1].ln_Name = GetCatalogStr( Catalog , MSG_WIN_PALETTE_DETAIL , Pens1Nodes[1].ln_Name );
  1416.     Pens1Nodes[2].ln_Name = GetCatalogStr( Catalog , MSG_WIN_PALETTE_TEXT , Pens1Nodes[2].ln_Name );
  1417.     Pens1Nodes[3].ln_Name = GetCatalogStr( Catalog , MSG_WIN_PALETTE_BRIGHT , Pens1Nodes[3].ln_Name );
  1418.     Pens1Nodes[4].ln_Name = GetCatalogStr( Catalog , MSG_WIN_PALETTE_DARK , Pens1Nodes[4].ln_Name );
  1419.     Pens1Nodes[5].ln_Name = GetCatalogStr( Catalog , MSG_WIN_PALETTE_SFILL , Pens1Nodes[5].ln_Name );
  1420.     Pens1Nodes[6].ln_Name = GetCatalogStr( Catalog , MSG_WIN_PALETTE_TFILL , Pens1Nodes[6].ln_Name );
  1421.     Pens1Nodes[7].ln_Name = GetCatalogStr( Catalog , MSG_WIN_PALETTE_BACK , Pens1Nodes[7].ln_Name );
  1422.     Pens1Nodes[8].ln_Name = GetCatalogStr( Catalog , MSG_WIN_PALETTE_HIGH , Pens1Nodes[8].ln_Name );
  1423.     Pens1Nodes[9].ln_Name = GetCatalogStr( Catalog , MSG_WIN_PALETTE_TXTMENU , Pens1Nodes[9].ln_Name );
  1424.     Pens1Nodes[10].ln_Name = GetCatalogStr( Catalog , MSG_WIN_PALETTE_BACKMENU , Pens1Nodes[10].ln_Name );
  1425.     Pens1Nodes[11].ln_Name = GetCatalogStr( Catalog , MSG_WIN_PALETTE_TRIM , Pens1Nodes[11].ln_Name );
  1426. }
  1427.  
  1428. void GetScreenWnd( void )
  1429. {
  1430.     ScreenPrefsNGad[0].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_SCREEN_DISPID , ScreenPrefsNGad[0].ng_GadgetText );
  1431.     ScreenPrefsNGad[3].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_SCREEN_RESTORE , ScreenPrefsNGad[3].ng_GadgetText );
  1432.     ScreenPrefsNGad[4].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_SCREEN_PALETTE , ScreenPrefsNGad[4].ng_GadgetText );
  1433.     ScreenPrefsNGad[6].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_SCREEN_TYPE , ScreenPrefsNGad[6].ng_GadgetText );
  1434.     ScreenPrefsNGad[8].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_SCREEN_WIDTH , ScreenPrefsNGad[8].ng_GadgetText );
  1435.     ScreenPrefsNGad[10].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_SCREEN_HEIGHT , ScreenPrefsNGad[10].ng_GadgetText );
  1436.     ScreenPrefsNGad[11].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_SCREEN_OVERSCAN , ScreenPrefsNGad[11].ng_GadgetText );
  1437.     ScreenPrefsNGad[12].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_SCREEN_DEFAULT , ScreenPrefsNGad[12].ng_GadgetText );
  1438.     ScreenPrefsNGad[13].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_SCREEN_AUTOSCROLL , ScreenPrefsNGad[13].ng_GadgetText );
  1439.     ScreenPrefsNGad[14].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_SCREEN_FONT , ScreenPrefsNGad[14].ng_GadgetText );
  1440.     ScreenPrefsNGad[15].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_SCREEN_SYSFONT , ScreenPrefsNGad[15].ng_GadgetText );
  1441.     Type0Labels[0] = GetCatalogStr( Catalog , MSG_WIN_SCREEN_PUBLIC , Type0Labels[0] );
  1442.     Type0Labels[1] = GetCatalogStr( Catalog , MSG_WIN_SCREEN_WB , Type0Labels[1] );
  1443. }
  1444.  
  1445. void GetMessages( void )
  1446. {
  1447.   int n = MSG_MESSAGE_CONTINUE;
  1448.   char **s=StrMessages;
  1449.  
  1450.     while ( n < MSG_MENU_PROJECT )
  1451.     {
  1452.     *s = GetCatalogStr( Catalog , n , *s );
  1453.     n++;
  1454.     s++;
  1455.     }
  1456. }
  1457.  
  1458. void GetIncludeList(void )
  1459. {
  1460.     CListeNGad[0].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_INCLUDE_TITLE , CListeNGad[0].ng_GadgetText );
  1461.     CListeNGad[1].ng_GadgetText = GetCatalogStr( Catalog , MSG_WIN_INCLUDE_EDIT , CListeNGad[1].ng_GadgetText );
  1462.     CListeNGad[2].ng_GadgetText = GetCatalogStr( Catalog , MSG_MESSAGE_ABORT , "_Cancel" );
  1463. }
  1464.  
  1465. void GetLocale(void)
  1466. {
  1467.     if (LocaleBase=OpenLibrary("locale.library",38))
  1468.     {
  1469.     Catalog=OpenCatalog(NULL,"project_handler.catalog",
  1470.               OC_BuiltInLanguage, "english",
  1471.               OC_Version,          0,
  1472.               TAG_DONE);
  1473.     GetMenu( );
  1474.     GetUseCancel( );
  1475.     GetTitles( );
  1476.     GetCompilerWnd( );
  1477.     GetLinkerWnd( );
  1478.     GetGenOptWnd( );
  1479.     GetDirWnd( );
  1480.     GetScreenWnd( );
  1481.     GetPaletteWnd( );
  1482.     GetMessages( );
  1483.     GetIncludeList( );
  1484.     }
  1485. }
  1486.  
  1487. void FreeLocale(void)
  1488. {
  1489.  if (LocaleBase) {
  1490.   if (Catalog) CloseCatalog(Catalog);
  1491.   CloseLibrary(LocaleBase);
  1492.  }
  1493. }
  1494.  
  1495.  
  1496. /****************************************************************************
  1497. ***                                      ***
  1498. ***    Programme principale comme l'on peut le constater                 ***
  1499. ***                                      ***
  1500. ****************************************************************************/
  1501.  
  1502. struct ExecBase *ExecBase;
  1503.  
  1504. int main( int argc , char **argv ) {
  1505.     ExecBase = *((APTR *)4);
  1506.     ROMVersion = ExecBase->LibNode.lib_Version;
  1507.     if ( ROMVersion >= 38 )
  1508.     GetLocale( );
  1509.     else
  1510.     MakeUseCancel( );
  1511.     if ( InitVar( ) ) {
  1512.     if ( !(SetupScreen( ) ) ) {
  1513.         if ( !OpenProjectWindow( ) ) {
  1514.         AddWinC( ProjectWnd , HandleProjectIDCMP );
  1515.         WinControl( );
  1516.         }
  1517.         CloseDownScreen( );
  1518.     }
  1519.     FreeVar( );
  1520.     }
  1521.     if ( ROMVersion >= 38 )
  1522.     {
  1523.     FreeLocale( );
  1524.     }
  1525.     return( 0 );
  1526. }
  1527.  
  1528. int wbmain( struct WBStartup *WB ) {
  1529.     main( 0 , (char **)WB );
  1530. }
  1531.  
  1532.